# -*- coding: utf-8 -*-
"""
    Time    : 2020/12/28 9:53 下午
    Author  : Thinkgamer
    File    : add05-含负数的升序数组按照绝对值重新排序.py
    Desc    : 腾讯视频一面
            eg：arr=[-3, -1, 0, 2, 4, 5]
            new_arr=[0, -1, 2, -3, 4, 5]
"""

"""
	最高效的思路，找到临界点
"""

arr = [-3, -1, 0, 2, 4, 5]
result = [0] * len(arr)
left = 0
right = len(arr) - 1
index = len(arr) - 1
while left <= right:
	if abs(arr[left]) >= abs(arr[right]):
		result[index] = arr[left]
		index -= 1
		left += 1
	else:
		result[index] = arr[right]
		index -= 1
		right -= 1

print(result)
	